package com.yuan.controller;


import com.yuan.bean.LibraryCard;
import com.yuan.bean.UserLogin;
import com.yuan.service.LibraryCardService;
import com.yuan.service.UserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.*;

@RestController
//@RequestMapping("/d")
public class FormController {

    @Autowired
    UserLoginService userLoginService;

    @Autowired
    LibraryCardService libraryCardService;
//    @RequestMapping ("/do")
//    public Map<String, String> user() {
////        System.out.println("收到/do请求");
////        long t = System.currentTimeMillis();//获得当前时间的毫秒数
////        Random r = new Random(t);
////        int ran1 = r.nextInt(100);    //每请求一个则会得到一个随机数
//
////        return "{\"id\":\""+ran1+"\"}";       //例如：{“id”：“20”}
//        Map<String, String> map = new HashMap<>();
//        map.put("name", "1");
//        map.put("age","10");
//        return map;
//    }

    @RequestMapping ("/do")
    public List<UserLogin> user() {
//
        List<UserLogin> userLogins = userLoginService.selectAll();
        return userLogins;
    }

    @RequestMapping("/aa")
    public boolean isReturn(){
        return true;
    }


//    @GetMapping("/lc")
//    public List<LibraryCard> libraryCards(HttpSession session){
//        final UserLogin user =(UserLogin) session.getAttribute("User");
//        Integer userId=user.getUserId();
//        final List<LibraryCard> libraryCards = libraryCardService.selectAllByUserId(userId);
//        return libraryCards;
//    }

}
